﻿using System.Net;
using AngryManagementMayhem.Controller;
using AngryManagementMayhem.Controller.NetworkObject;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.Global;
using Transformable_Engine_v2.Engine.Network;
using Transformable_Engine_v2.Engine.Network.Object;

namespace AngryManagementMayhem.GameCode.Screens.MainMenuScreen
{
    public class SelectTeamsScreen : Screen
    {
        public override void LoadContent()
        {
            GameController.OnNetworkSearchGame += NotifyGamePresence;

            base.LoadContent();
        }

        void NotifyGamePresence(IPEndPoint sender, SearchGame searchGame)
        {
            Log.LogDebug("Search received: " + searchGame);

            GameController.SendMessageToClient(sender.Address,
                new SearchGameResponse
                    {
                        GameMap = GameController.Map,
                        GameMaxPlayers = GameController.MaxPlayers,
                        GameMode = GameController.Mode,
                        GameName = GameController.GameName,
                        GamePlayers = 1
                    }.ToNetworkObject());
        }
    }
}